﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PurviewMain.aspx.cs" Inherits="ZX.WebApp.EditWidows.SysManager.PurviewMain" %>

<%@ Register Assembly="ZX.Web.UI.Controls" Namespace="ZX.Web.UI.Controls" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>权限管理</title>
    <!--CSS file (default YUI Sam Skin) -->
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/reset-fonts-grids/reset-fonts-grids.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/menu/assets/skins/sam/menu.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link type="text/css" rel="stylesheet" href="../../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <link href="../../Scripts/yui_2.9.0/build/treeview/assets/treeview-core.css" rel="stylesheet"
        type="text/css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/fonts/fonts-min.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/treeview/assets/skins/sam/treeview.css" />
    <!--begin custom header content for this example-->
    <style type="text/css">

.yui-skin-sam table {
	width: 100%;
}
    #tree {background: #fff; padding:1em;}

    #button-example-form fieldset, 
    #button-example-form fieldset div {

        border: 2px groove #ccc;
        margin: .5em;
        padding: .5em;

    }

    .yui-button#pushbutton2 button,
    .yui-button#pushbutton5 button, 
    .yui-button .Add button {
        background: url(../button/assets/add.gif) center center no-repeat;
        text-indent: -4em;
        overflow: hidden;
        padding: 0 .75em;
        width: 2em;
        *margin-left: 4em;   /* IE only */
        *padding: 0 1.75em;  /* IE only */

    }
    
    .yui-button#pushbutton3 button,
    .yui-button#pushbutton6 button, 
    .yui-button#pushbutton9 button {

        padding-left: 2em;
        background: url(../button/assets/add.gif) 10% 50% no-repeat;
    
    }
    <% =DataTableCss %>
</style>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <!-- OPTIONAL: JSON Utility (for DataSource) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <!-- OPTIONAL: Connection Manager (enables XHR for DataSource) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <!-- OPTIONAL: Get Utility (enables dynamic script nodes for DataSource) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <!-- OPTIONAL: Drag Drop (enables resizeable or reorderable columns) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <!-- OPTIONAL: Calendar (enables calendar editors) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/calendar/calendar-min.js"></script>
    <!-- Source files -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/treeview/treeview-min.js"></script>
    <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
</head>
<body class="yui-skin-sam">
    <form id="form1" runat="server">
    <!-- 工具栏 -->
    <div id="listpage">
        <div id="toolbar" style="margin: 2px;">
            <button type="button" id="Button1" name="btnAddNew">
                设置功能</button>
            <button type="button" id="btnQuery" name="btnQuery">
                查找</button>
        </div>
        <div id="data">
            <div id="json">
            </div>
        </div>
    </div>
    <div id="dialog1" class="yui-pe-content">
        <div class="hd">
            功能设置</div>
        <div class="bd">
            <iframe id="EditUIWindow" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    </form>
</body>
<script type="text/javascript">
 (function () {
        var Dom = YAHOO.util.Dom,
        Event = YAHOO.util.Event;

        Event.onDOMReady(function () {
        var layout = new YAHOO.widget.Layout({
                units: [
                { position: 'center', body: 'data', gutter: '1 1', collapse: true,scroll: true }
                
            ]
            });
            layout.render();
        });
        BindData();

    })();
   
      //设置角色
    var pId;
    var conditonId;
    var selectId;
    var fnAdd = function(){
        var recordID = myDataTable.getSelectedRows()[0];
        record = myDataTable.getRecord(recordID);
        pId = record.getData("<%=EntityId%>");
        conditonId = "UserID";
        selectId = "RoleID";
        document.getElementById("EditUIWindow").src="../YUITree.aspx?masterentity=SysRoleFunction&masterPara=SysFunction|Name|FunctionID|ParentID|FunctionPath|True";
        YAHOO.example.container.dialog1.show();
    }
    function AddButton() {
        var button = document.createElement('button');
        button.innerHTML = 'add tab';
        YAHOO.util.Event.on(button, 'click', addTab);
        tabView.appendChild(button);
    }




var mDataTable;
function BindData() {
        YAHOO.example.XHR_JSON = function() {
            var formatUrl = function(elCell, oRecord, oColumn, sData) {
                elCell.innerHTML = "<a href='" + oRecord.getData("ClickUrl") + "' target='_blank'>" + sData + "</a>";
            };
        
            var formatRating = function(elCell, oRecord, oColumn, sData) {
                elCell.innerHTML = (sData === null) ? "N/A" : YAHOO.util.Number.format(sData);
            };

            var myColumnDefs = [
                 <% =DataFields %>
            ];

            var myDataSource = new YAHOO.util.DataSource("../../Extend/AjaxData/JSONList.aspx?");
            myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
            myDataSource.connXhrMode = "queueRequests";
            myDataSource.responseSchema = {
                resultsList: "rows",
                //fields: ["EntityName", "THCaption", "Field", { key: "Rating.AverageRating", parser: "number" }, "Width"]
                fields: [<% =DataColums %>]
            };
        
            this.myDataTable = new YAHOO.widget.DataTable("json", myColumnDefs,
                    myDataSource, {initialRequest: "entity=<%=EntityName%>&order=<% =Order %>&zip=94089&results=10&output=json&r="+Math.random()+"",selectionMode:"single"  });
            mDataTable =this.myDataTable;
            var mySuccessHandler = function() {
                this.set("sortedBy", null);
                this.onDataReturnAppendRows.apply(this,arguments);
            };
            var myFailureHandler = function() {
                this.showTableMessage(YAHOO.widget.DataTable.MSG_ERROR, YAHOO.widget.DataTable.CLASS_ERROR);
                this.onDataReturnAppendRows.apply(this,arguments);
            };
            var callbackObj = {
                success : mySuccessHandler,
                failure : myFailureHandler,
                scope : myDataTable
            };
            var onRowDoubleClick =  function () {
            // 取得ID值
            var oRecord;
                var selectRows = myDataTable.getSelectedRows();
                if(selectRows.length!=null && selectRows.length==1)
                {                  
                    fnAdd();
                }
                else{
                    alert("请选中一行");
                }     
            }    
	        // Subscribe to events for row selection 
	        this.myDataTable.subscribe("rowMouseoverEvent", this.myDataTable.onEventHighlightRow); 
	        this.myDataTable.subscribe("rowMouseoutEvent", this.myDataTable.onEventUnhighlightRow); 
            this.myDataTable.subscribe("rowClickEvent", this.myDataTable.onEventSelectRow); 
            this.myDataTable.subscribe("rowDblclickEvent", onRowDoubleClick); 
            
 
            // Programmatically select the first row 
            this.myDataTable.selectRow(this.myDataTable.getTrEl(0)); 
    
            hideCol();
        }();
    }

    //隐藏/栏位
    function hideCol(){ mDataTable.hideColumn(parseInt(0)); mDataTable.refreshView(); };
//YAHOO.util.Event.addListener(window, "load", BindData);
YAHOO.namespace("example.container");
 
YAHOO.util.Event.onDOMReady(function () {

	// Define various event handlers for Dialog
	var handleSubmit = function() {
        var editwindow = document.getElementById("EditUIWindow");
        if(editwindow)
        {
           editwindow.contentWindow.Save();
        }
	};
 
	var handleCancel = function() {
		this.cancel();
	};
	var handleSuccess = function(o) {
		var response = o.responseText;
		response = response.split("<!")[0];
		document.getElementById("resp").innerHTML = response;
	};
	var handleFailure = function(o) {
		alert("Submission failed: " + o.status);
	};
   
 
    // Remove progressively enhanced content class, just before creating the module
    YAHOO.util.Dom.removeClass("dialog1", "yui-pe-content");
 
	// Instantiate the Dialog
	YAHOO.example.container.dialog1 = new YAHOO.widget.Dialog("dialog1", 
							{ width : "450px",
                              height:"300px",
							  fixedcenter : true,
							  visible : false, 
							  constraintoviewport : true,
							  buttons : [ { text:"保存", handler:handleSubmit, isDefault:true },
								      { text:"取消", handler:handleCancel } ]
							});
    
	// Validate the entries in the form to require that both first and last name are entered
	YAHOO.example.container.dialog1.validate = function() {
		var data = this.getData();
		if (data.firstname == "" || data.lastname == "") {
			alert("Please enter your first and last names.");
			return false;
		} else {
			return true;
		}
	};
 
    	YAHOO.example.container.dialog1.callback = { success: handleSuccess,
						         failure: handleFailure };
	    YAHOO.example.container.dialog1.render();
	    YAHOO.util.Event.addListener("btnAddNew", "click", YAHOO.example.container.dialog1.show, YAHOO.example.container.dialog1, true);
	//YAHOO.util.Event.addListener("hide", "click", YAHOO.example.container.dialog1.hide, YAHOO.example.container.dialog1, true);
});

	//Add an onDOMReady handler to build the tree when the document is ready
</script>
</html>
